/**
 *
 * 跟据数据字典配置的天数，选择几天这样的日期范围
 *
 * */
import {ICellInputProps} from "@/biz-components/claim-items/components-v2/cell-input";
import {useDictionaryOptions} from "@/common-data-source/dictionary";
import {Select} from "antd";
import {useEffect} from "react";


export function SelectDays(props: ICellInputProps<number | null>) {
	const options = useDictionaryOptions('CLAIM_PYMT_INST_PAY_DATE');
	const value = typeof props.value === 'number' ? props.value.toString() : '';
	return (
		<Select<string> value={value} onChange={(v) => {
			if(v) {
				let n = Number(v);
				props.onChange(isNaN(n) ? null : n);
			} else {
				props.onChange(null);
			}
		}}>
			{
				options.map((item) => {
					return (
						<Select.Option value={item.value} key={item.value}>{item.name}</Select.Option>
					)
				})
			}

		</Select>
	)
}
// @ts-ignore
SelectDays.defaultValue = null;
